Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Record handled report info during initial write #322

Merged
merged 1 commit into from
Dec 19, 2018

Conversation

kattrali
Copy link
Contributor

@kattrali kattrali commented Dec 17, 2018

Before this change, information which is not part of the standard KS
report was serialized in the onCrash callback, which is shared between
notify() and fatal reports, and used simultaneously in the case that
two reports are generated at once.

This change serializes information which applies to only a single report
into the initial report, reserving the onCrash handler for shared global
state which does not become null once set, like session information, and
handlers which are only run in the event of a crash (by definition,
occurring only once).

Fixes a case where handled state can be reported incorrect for notify()
requests as the shared handled state was cleared/set to null by a
concurrent request.

Tests

The existing tests cover report info serialization and I broke each component at least once. The case which this changeset fixes its hard to boil down to a test case as its the result of a timing issue.

Review

Outstanding Questions

  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

@kattrali kattrali force-pushed the kattrali/serialize-handled-info-directly branch from 6354abb to 995c13e Compare December 17, 2018 08:34
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general approach of removing mutable shared state is good, and after manually testing a handled/unhandled exception, the implementation appears to work.

I think we need to add test coverage for the original scenario before releasing, as that will help verify that we've solved the original problem. If automated tests are impractical, then we need to perform integration testing via some other method, such as via manual testing.

Source/BugsnagNotifier.m Show resolved Hide resolved
Source/BugsnagNotifier.m Show resolved Hide resolved
appState:[self.state toDictionary]
callbackOverrides:report.overrides
metadata:[report.metaData copy]
config:[self.configuration.config toDictionary]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Access to self.configuration.config was previously synchronized behind a lock - is this access also synchronized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, these values were mutated in this block. Removing the mutation removed the need for a lock.

Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m Outdated Show resolved Hide resolved
Before this change, information which is not part of the standard KS
report was serialized in the onCrash callback, which is shared between
notify() and fatal reports, and used simultaneously in the case that
two reports are generated at once.

This change serializes information which applies to only a single report
into the initial report, reserving the onCrash handler for shared global
state which does not become null once set, like session information, and
handlers which are only run in the event of a crash (by definition,
occurring only once).

Fixes a case where handled state can be reported incorrect for notify()
requests as the shared handled state was cleared/set to null by a
concurrent request.
@kattrali kattrali force-pushed the kattrali/serialize-handled-info-directly branch from 995c13e to 733efbe Compare December 18, 2018 13:16
@kattrali kattrali merged commit 76b06e8 into master Dec 19, 2018
@kattrali kattrali deleted the kattrali/serialize-handled-info-directly branch December 19, 2018 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants